
function f(n:longint):longint;
var
	i:longint;
	s:longint=0;
begin
	for i:=1 to n-1 do
	if n mod i = 0 then
		s:=s+i;
	f:=s;
end;

var
	i,n:longint;
begin
	for i:=1 to 1000 do
	begin
		n:=f(i);
		if (i<n) and (n<=1000) and (f(n)=i) then
		writeln(i,' ',n);
	end;
end.
